package com.wuseguang.springcloud.dao.jdbc;

import com.wuseguang.springcloud.JdbcTemplate.BaseTemplate;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

@Repository
public class AttendClassTimeJdbc extends BaseTemplate {

    /**
     * 查询上课时间
     * @param schoolId 学校id
     * @return
     */
    public Map<String, Object> findAttendClassTime(String schoolId) {
        //查询上课时间SQL
        String  sql = "select current_section,start_time,end_time from attend_class_time where school_id = ?";

        return  dao.query(sql,new Object[]{schoolId}, rs -> {

            Map<String ,Object> map = new HashMap<String ,Object>();
            while(rs.next()){
                map.put(rs.getString("current_section"),rs.getString("start_time")+"-"+rs.getString("end_time"));
            }
            return map;
        });
    }
}
